<?php
require_once "my_profile_left_pane.php";

	
	
	if($_SESSION['user_id_sess']=="") {
		echo "<script type='text/javascript'> window.location='index.php?signin&url=profile'; </script>";
	}
	require_once "includes/class/member_management.class.php";
	$userId = $_SESSION['user_id_sess'];	
	$usrObj = new member_management;
	
	
	
	
	if(isset($_POST['editProfile'])) {
		
		$password		=	$_REQUEST['password'];
		$secret_question	=	$_REQUEST['secretQuestion'];
		$secret_answer		=	$_REQUEST['secretAnswer'];
		
		
		
		$sqlUpdUsr = "UPDATE tbl_users SET
			password='".$password."',
			secret_question='".$secret_question."',
			secret_answer='".$secret_answer."'
			WHERE user_id='$userId'";
		$rstUpdUsr = mysql_query($sqlUpdUsr) or die(mysql_error());
		if($rstUpdUsr) { 
			$msg = "Your profile updated successfully.";
		}
		else { $msg=""; }					
	}
	
	$userInfo = $usrObj->getMemberById($userId);
	
?>
<script src="<?php echo $base_url?>js/jquery.custom_radio_checkbox.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
	$(".radio").dgStyle();
	$(".checkbox").dgStyle();
	toggle_chat_img(<?php echo $userInfo['chat_status']; ?>)
});
</script>
<div class="releftbox_out">
	<div class="releftbox_top">&nbsp;</div>
	<div class="releftbox_repeat">
		<h1 style="float:left; width:100%; text-align:center; margin-top:-10px;">Comm. Options</h1>
		<span style="float:left; width:96%; text-align:right; padding:0px5px 5px 0px;"><a href="javascript:void(0);">FAQ</a></span>
		<div id="messageAreaTop" style="margin:10px 0px 10px 20px; float:left;"><?php if(isset($msg)) echo "<b>".$msg."</b>"; ?></div>
		<form enctype="multipart/form-data" name="frmEditProfile" method="post" action="" onSubmit="return validateForm();">
		<div class="blue_box">
			<div class="bluebar_left"></div>
			<div class="bluebar_center"><span>Chatting and Blocked users</span></div>
			<div class="bluebar_right"></div>
		</div>
		
		<div class="blue_box">
			<div class="form_field_box_full">
				<label for="chat_option" id="lblchat_option">Chat Options:</label>
				<span style="padding-left:15px">
					<img align="absmiddle" onclick="toggle_chat_img(1)" alt="ON" id="chat_on" src="images/on_big_03.png"> &nbsp;OR&nbsp;
					<img align="absmiddle" alt="OFF" onclick="toggle_chat_img(0)" style="cursor: pointer;" id="chat_off" src="images/off_small_07.png">
					<input type="hidden" value="1" id="chat_option" name="chat_option" />
					<script>
					function toggle_chat_img(a)
					{
						if(a==0)
						{
							$('#chat_on').attr({src: "images/on_small_07.png", title: "ON", alt: "ON"});
							$('#chat_on').css('cursor','pointer');
							$('#chat_off').attr({src: "images/off_big_03.png", title: "OFF", alt: "OFF"});
							$('#chat_off').css('cursor','default');
						}
						else
						{
							$('#chat_on').attr({src: "images/on_big_03.png", title: "ON", alt: "ON"});
							$('#chat_on').css('cursor','default');
							$('#chat_off').attr({src: "images/off_small_07.png", title: "OFF", alt: "OFF"});
							$('#chat_off').css('cursor','pointer');
						}
						$('#chat_option').val(a);
						
						var url = "change_chat_flag.php";
						$.post(url,
						{ 'chat_status': a, 'user_id': <?php echo $userId;?>},
						function(data)
						{
							//Do nothing
							
						},
						'html');
					}
					</script>
				</span>
			</div>
			<div class="blue_box">
				<font style="color:#BAB4B4; padding:10px; width:550px; font-size:13px; float:left;">NOTE: Turning off the chating option will turn off your ability to chat and for any user to contact you  by chat.</font>
			</div>
			<div class="blue_box">
				<div class="form_field_box_full">
					<label for="blocked_users" id="lblblocked_users">Blocked Users:</label>
				</div>
			</div>
		</div>
		
		
		
		<div class="blue_box">
			&nbsp;
		</div>
		
		
		<div id="errMsg" style="margin:10px 0px 10px 20px; float:left;"></div>
		</form>
	</div>
		
	<div class="releftbox_bot">&nbsp;</div>
</div>		
		
		
